<?php 
class db_user_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
	function test(){
		return "test1";                
               
    }
    // check username
    function checkUserName($username=null){
        $where	= array("username"=>$username);
        $query	= $this->db
                            ->where($where)
                            ->get(PREFIX.'user');
        $count 	= $this->db->affected_rows();
        if($count>0) return 1;
        return false;
    }

    // check login by username
    function checkLogin($username=null,$password=null){
    $where=array("username"=>$username,"password"=>$password);
    $query=$this->db
                                    ->select("uid,ugid,username,showname,email,fullname,coin,coinpending,coinavailable")
                                    ->where($where)
                                    ->get(PREFIX.'user');       
        return $query->result();
    }
    
    //get user
    function getUser($params=array()){
        $query = $this->db->select("uid,ugid,username,showname,email,fullname,coin,coinpending,coinavailable")
                            ->where($params)
                            ->get(PREFIX."user");
        return $query->result();
    }
}
?>
